//
//  SISSHouseProgressUploadPictureBottomInfoViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/12/26.
//  Copyright © 2018 优房网. All rights reserved.
//

#import "SISSHouseProgressUploadPictureBottomInfoViewController.h"
#import "SISSHouseProgressUploadPictureBottomInfoShowViewController.h"
#import "SISSNetworkingManager+HouseProgress.h"

@interface SISSHouseProgressUploadPictureBottomInfoViewController ()

@end

@implementation SISSHouseProgressUploadPictureBottomInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"上传担保公司批单";
    self.titleStr = @"上传担保公司批单附件";
}

- (void)setOrganApprovalModel:(SISSOrganApprovalModel *)organApprovalModel {
    _organApprovalModel = organApprovalModel;
    self.infoStr = organApprovalModel.otherdesc;
}

- (void)confirmButtonClickAction {
    [self.view endEditing:YES];
    
    NSString *otherdesc = self.infoStr.length ? self.infoStr : @"";
    if (self.organApprovalModel) {
        NSDictionary *parameters = @{
                                     @"id": self.organApprovalModel.ID,
                                     @"saId": [SISSUserAccount shared].saId,
                                     @"spId": [SISSUserAccount shared].spId,
                                     @"ahbpId": self.ahbpId,
                                     @"otherdesc": otherdesc,
                                     };
        [kNetworkNoUTF8Manager updateOrganApprovalInfoWithParamters:parameters images:self.images success:^(id responseObject) {
            if ([responseObject[@"code"] integerValue] == 200) {
                SISSHouseProgressUploadPictureBottomInfoShowViewController *vc = [[SISSHouseProgressUploadPictureBottomInfoShowViewController alloc] init];
                vc.ahbpId = self.ahbpId;
                [self.navigationController pushViewController:vc animated:YES];
            }
        } failed:^(NSError *error) {
            NSLog(@"%@",error);
        }];
    } else {
        if (!self.images.count) {
            [SISSTools showSVWithTitle:@"请选择担保公司批单"];
            return;
        }
        NSDictionary *parameters = @{
                                     @"saId": [SISSUserAccount shared].saId,
                                     @"spId": [SISSUserAccount shared].spId,
                                     @"ahbpId": self.ahbpId,
                                     @"otherdesc": otherdesc,
                                     };
        [kNetworkNoUTF8Manager insertOrganApprovalInfoWithParamters:parameters images:self.images success:^(id responseObject) {
            if ([responseObject[@"code"] integerValue] == 200) {
                SISSHouseProgressUploadPictureBottomInfoShowViewController *vc = [[SISSHouseProgressUploadPictureBottomInfoShowViewController alloc] init];
                vc.ahbpId = self.ahbpId;
                [self.navigationController pushViewController:vc animated:YES];
            }
        } failed:^(NSError *error) {
            NSLog(@"%@",error);
        }];
    }
    
}


@end
